import java.io.File;
import java.util.Scanner;

public class PriceCalculator {
    public static void main(String[] args) {
        File file = new File("prices.txt"); 
        Scanner sc = null;
        int count = 0;
        double sum = 0;

        try {
            sc = new Scanner(file);
            sc.useDelimiter("[^0-9]+");

            while (sc.hasNextInt()) {
                int price = sc.nextInt(); 
                count++;
                sum += price;
                System.out.println("价格: " + price + "元");
            }

            if (count > 0) { 
                double average = sum / count;
                System.out.printf("平均价格: %.2f元%n", average);
            } else {
                System.out.println("未找到价格数据。");
            }
        } catch (Exception exp) {
            System.out.println("错误: " + exp.getMessage());
        } finally {
            if (sc != null) {
                sc.close();
            }
        }
    }
}